#include "util.h"
#include <stdint.h>
#include <stdio.h>

// BKDR hash
unsigned str_hash(const char *str, size_t n) {
  unsigned seed = 131;
  unsigned hash = 0;

  while (n-- && *str) {
    hash = hash * seed + (*str++);
  }

  return hash & 0x7fffffff;
}
